package collection;

import com.sun.xml.internal.ws.api.model.wsdl.WSDLOutput;

import java.util.*;

public class SortString {
    public static void main(String[] args) {
        /*List<String> list=new ArrayList<>();
        list.add("刘思甜");
        list.add("许威");
        list.add("是个大帅哥");
        System.out.println(list);
        Collections.sort(list, new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {

                return o1.length()-o2.length();
            }
        });
        System.out.println(list);*/



        List<String> tt=new ArrayList<>();
        tt.add("我是大");
        tt.add("帅哥");
        tt.add("你是个鄂弼");
        System.out.println(tt);

        Collections.sort(tt, new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                return o1.length()-o2.length();
            }
        });
        System.out.println(tt);

        Collections.sort(tt, ( o1,  o2) ->o1.length()-o2.length());






















    /*    List<String> list =new ArrayList<>();
        list.add("jack");
        list.add("rose");
        list.add("tom");
        list.add("jerry");
        list.add("black");
        list.add("Kone");
        System.out.println("list:"+list);
        Collections.sort(list);
        System.out.println("排序后："+list);
        //对英文字符串排序时，按首字母的ASCII码排序
        //首字母一样，按第二个字母排

        Collections.reverse(list);
        System.out.println("倒序后："+list);*/
    }
}
